package com.wawei.seeds.services;

import android.content.Context;
import android.os.Handler;

import com.wawei.seeds.utils.RetrofitNetworkService;

import java.util.ArrayList;
import java.util.List;

import retrofit.RestAdapter;

/**
 * Created by parker on 15/6/7.
 */
public class SwitchImagesServiceHandler {
    private Context context;

    public SwitchImagesServiceHandler(Context context) {
        this.context = context;
    }

    /**
     * Retrieve images from remote server async. The number of images must be two or more.
     *
     * @param restAdapter   The adapter for calling restful service
     * @param count         The number of images
     * @param handler       The bridge between background thread and ui main thread
     * @param handlerTag    The tag for identifying the method caller
     */
    public void retrieveImages(RestAdapter restAdapter, int count,
                                           final Handler handler, final Integer handlerTag){
        if(count < 2){
            throw new IllegalArgumentException("The number of images must be two or more.");
        }
        //TODO: Get real images from the remote server
        List<String> imagesMock = new ArrayList<>(2);
        imagesMock.add("http://skepticfreethought.com/scrapbookoftruth/wp-content/uploads/sites/18/2015/02/Beauty2.jpg");
        imagesMock.add("http://upload.jashnname.com/UploadedFiles/Core/Images/8ae6b53a-2f23-4a61-81cd-c8d6e6058c92.jpg");
        RetrofitNetworkService.handleSuccess(handler, handlerTag, imagesMock.toArray());
    }
}
